<%@page import="classes.User"%>
<%@page import="classes.AccountManager"%>
<%@page import="java.util.ArrayList"%>
<%@page import="classes.Subject"%>
<%@page import="classes.SubjectManager"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>edit subject</title>
</head>
<body>


<%
	SubjectManager subManager = (SubjectManager)application.getAttribute(SubjectManager.SUBJECTMANAGER);
	
	String subjectname = request.getParameter("subject");
	if(subjectname != null){
		out.println("Change values and hit submit button to save changes");		
		Subject subject = subManager.getSubject(subjectname);
		ArrayList<String> lecturers = subject.getLecturers();
		
		out.println("<form action=\"editSubject.jsp\">");
		out.println("<p>subject name: <input type=\"text\" name=\"subjectname\" value=" + subject.getSubjectName() + "></p>");		
		out.println("<input type=\"hidden\" name=\"oldSubjectname\" value=" + subjectname + ">");
		out.println("<input type=submit value=\"change name\">");
		out.println("</form>");
		
	}
	else{
		String oldSubjectname = request.getParameter("oldSubjectname");
		Subject subject = subManager.getSubject(oldSubjectname);
		subject.setSubjectName(request.getParameter("subjectname"));
	
		ArrayList<String> lecturers = subject.getLecturers();
	
		out.println("<form action=\"editSubject.jsp\">");
		out.println("<p>subject name: <input type=\"text\" name=\"subjectname\" value=" + subject.getSubjectName() + "></p>");		
		out.println("<input type=\"hidden\" name=\"oldSubjectname\" value=" + subjectname + ">");
		out.println("<input type=submit value=\"change name\">");
		out.println("</form>");
		
		out.println("<p>changed<p>");
		
	}
	
	out.println("<a href=\"subjects.jsp\">go back</a>");
%>


</body>
</html>